<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>循环精灵图</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }
         li {
             list-style-type: none;
         }
         .box {
             width: 250px;
             height: 100px;
         }
         .box li {
             float: left;
             width: 95px;
             height: 97px;
             background-color: pink;
             margin: 15px;
             background: url(精灵图.PNG) no-repeat;
         }
    </style>
</head>
<body>
    <div class="box">
        <ul>
            <li></li>
            <li></li>
            <li></li>
            <li></li>
            <li></li>
            <li></li>
        </ul>
    </div>
    <script>
        var lis = document.querySelectorAll('li')
        for (var i = 0; i < lis.length ; i++) {
            var index = i * 13;
            lis[i].style.backgroundPosition = '-' + index + '0' + 'px';
        }
    </script>
</body>
</html>